package mid

import "strings"

func Convert(s string, numRows int) string {
	if numRows < 2 {
		return s
	}
	rows := make([]string, numRows)
	i, flag := 0, -1
	for _, c := range s {
		rows[i] += string(c)
		if i == 0 || i == numRows-1 {
			flag = -flag
		}
		i += flag
	}
	result := strings.Join(rows, "")
	return result
}
